import java.net.*; 
import java.io.*; 
 
public class SocketClient extends Socket
{ 
	public BufferedReader in = null; 
    public PrintWriter out = null;
    public Socket s;
    public int betValue;
    public int raiseValue;
    public int bankRollValue=0;
    public int maxBet;
    boolean connected = false;
    String message;
    MsgThread msg;
	
    public void connect()
    { 
    	String host="localhost";
        if(host == "") 
        { 
            System.out.println("Usage : SocketClient <serverName>"); 
            return; 
        } 
        try
        { 
            s = new Socket(host, 11112); 
        }        
        catch(UnknownHostException uhe) 
        { 
            System.out.println("Unknown Host :" + host); 
            s = null; 
        } 
        catch(IOException ioe) 
        { 
            System.out.println("Cant connect to server at 11111. Make sure it is running."); 
            s = null; 
        } 
         
        if(s == null) 
            System.exit(-1); 
       
        try
        {
        	in = new BufferedReader(new InputStreamReader(s.getInputStream())); 
        	out = new PrintWriter(new OutputStreamWriter(s.getOutputStream()));
        	msg= new MsgThread(in);
        	msg.start();
        	connected = true;
        }
        catch(IOException ioe) 
        { 
            System.out.println("Exception during communication. Server probably closed connection."); 
        }
        
    }
    void sendMsg(String action)
    {
	   
	        out.println(action); 
	        out.flush();
	       
    }
    void sendMsg(String action, int value)
    {
    	
    }
    void disconnect()
    { 
        try
        { 
        	msg.interrupt();
        	sendMsg("Quit");
            out.close(); 
            in.close(); 
            s.close(); 
        } 
        catch(Exception e) 
        { 
            e.printStackTrace(); 
        }                
    }
	
}